<template>
  <div class="login">
    <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
      <div style="text-align:center;margin:0 auto;" id="code"></div>
      <div>
        <el-button style="margin:0px 0px 25px 0px;" @click="resultTool" type="text">账号登录</el-button>
      </div>

      <el-dialog
        :title="admit.title"
        :visible.sync="admit.open"
        width="20%"
        >
        <span style="font-size: 22px"><b>欢迎{{loginForm.username}}使用</b></span>
        <span slot="footer" class="dialog-footer">
    <el-button @click="handleBack">返回首页</el-button>
    <el-button type="primary" @click="handleLogin">进入后台</el-button>
  </span>
      </el-dialog>

    </el-form>
    <!--  底部  -->
    <!--<div class="el-login-footer">
      <span>Copyright © 2018-2022 ruoyi.vip All Rights Reserved.</span>
    </div>-->
  </div>
</template>

<script>
import { getCodeImg, getAccessToken} from "@/api/login";
import Cookies from "js-cookie";
import { encrypt, decrypt } from '@/utils/jsencrypt'
import WwLogin from "@/api/module/cjl/wwLogin-1.0.0";
export default {
  name: "Login",
  data() {
    return {
      radio: 11,
      admit:{
        // 是否显示弹出层（用户查询）
        open: false,
        // 弹出层标题（用户查询）
        title: "",
      },
      codeUrl: "",
      loginForm: {
        username: "",
        password: "",
        rememberMe: false,
        code: "",
        uuid: "",
      },
      loginRules: {
        username: [
          { required: true, trigger: "blur", message: "请输入您的账号" }
        ],
        password: [
          { required: true, trigger: "blur", message: "请输入您的密码" }
        ],
        code: [{ required: true, trigger: "change", message: "请输入验证码" }]
      },
      loading: false,
      // 验证码开关
      captchaEnabled: true,
      // 注册开关
      register: false,
      redirect: undefined
    };
  },
  watch: {
    $route: {
      handler: function(route) {
        this.redirect = route.query && route.query.redirect;
      },
      immediate: true
    }
  },
  mounted(){
    window.WwLogin({
      "id" : "code",
      "appid" : "ww3c8d31017de5aa90",
      "agentid" : "1000202",
      "redirect_uri" :"http://cxcycgzh.bhu.edu.cn/",
      "state" : "STATE",
      "href" : "",
    });
  },
  created() {
    this.getCode();
    this.getCookie();
  },
  methods: {
    resultTool(){
      this.$router.push({path: "/login1"});
    },
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.login {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background-image: url("../assets/images/login-background.jpg");
  background-size: cover;
}
.title {
  margin: 0px auto 30px auto;
  text-align: center;
  color: #707070;
}

.login-form {
  border-radius: 6px;
  background: #ffffff;
  width: 400px;
  padding: 25px 25px 5px 25px;
  .el-input {
    height: 38px;
    input {
      height: 38px;
    }
  }
  .input-icon {
    height: 39px;
    width: 14px;
    margin-left: 2px;
  }
}
.login-tip {
  font-size: 13px;
  text-align: center;
  color: #bfbfbf;
}
.login-code {
  width: 33%;
  height: 38px;
  float: right;
  img {
    cursor: pointer;
    vertical-align: middle;
  }
}
.el-login-footer {
  height: 40px;
  line-height: 40px;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #fff;
  font-family: Arial;
  font-size: 12px;
  letter-spacing: 1px;
}
.login-code-img {
  height: 38px;
}
</style>
